package com.memoir.jpa.controller;

import com.memoir.jpa.model.TodoDto;
import com.memoir.jpa.service.TodoPagingAndSortingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * jpa注释在service层
 */

@RestController
@RequestMapping("/todo")
public class TodoPagingAndSortingController {

    @Autowired
    private TodoPagingAndSortingService todoService;

    @RequestMapping(value = "/find/sort",method = RequestMethod.GET)
    public List<TodoDto> findAllBySort(){
        return todoService.findAllBySort();
    }

    //利用pageabel实现分页
    @RequestMapping(value = "/find/page/{pageNum}",method = RequestMethod.GET)
    public List<TodoDto> findAllByPage(@PathVariable Integer pageNum){
        return todoService.findAllByPage(pageNum);
    }

}
